package com.shanglv.web.common.directive;

import freemarker.core.Environment;
import freemarker.template.TemplateDirectiveBody;
import freemarker.template.TemplateDirectiveModel;
import freemarker.template.TemplateException;
import freemarker.template.TemplateModel;
import org.apache.commons.lang.StringUtils;

import java.io.IOException;
import java.util.Map;

public class ExtendsDirective extends BaseDirective implements TemplateDirectiveModel {


    @Override
    @SuppressWarnings({ "unchecked", "rawtypes" })
    public void execute(Environment env, Map params, TemplateModel[] loopVars, TemplateDirectiveBody body) throws TemplateException, IOException {
        String nameValue = getParams(params, ATTR_NAME);
        if (StringUtils.isNotBlank(nameValue)) {
            env.include(nameValue, DEFAULT_ENCODING, true);
        }
    }
}
